package com.first.common.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @program:
 * @description:
 * @author: 张玉森
 * @create:
 **/
@Configuration
@EnableSwagger2 //开启swagger注解驱动
public class SwaggerConfig {
    @Bean //把方法返回的数据对象 交于spring容器管理
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("QY163First")
                .apiInfo(getInfo())
                .select()
                .paths(Predicates.not(PathSelectors.regex("/error.*"))) //只为com.ykq.controller包下的类生成接口文档
                .build();
    }

    private ApiInfo getInfo(){
        Contact DEFAULT_CONTACT = new Contact("First", "http://wzzzz.com", "121@qq.com");
        return new ApiInfo("QY163在线教育平台", "在线教育平台", "1.1.0", "http://www.WBG.com",
                DEFAULT_CONTACT, "Apache 3.0", "http://www.ascaaaa.com", new ArrayList<VendorExtension>());
    }
}